<?php
require_once  '../classes/ConnectionDB.php';
require_once  '../classes/ClasseManager.php';
$db =ConnectionDB::getInstance()->connectToDB();
$userLoggato = $_COOKIE['username'];

$result = ClasseManager::getInstance()->getClassiByUser($db, $userLoggato);
$result->bind_result($codiceClasse, $classe,$sezione, $descrizione);

//echo ' cc ' . count($result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Nuovo Studente</title>
        <style type="text/css">
            @import url("../css/template.css");
            a#viewcss{color: #00f;font-weight: bold}
            a  {color: white;}
        </style>
    </head>
    <body>
          <?
        if(count($result)==1){
            ?>
        <div style="padding-top: 15%; color: white; ">
            <center>
                <h3>Attenzione!!! Per poter inserire uno studente bisogna prima inserire una classe a cui associare lo studente.<br/><br /> <br />
                    Per inserirla clicca <a href="nuovaClasse.php">qui</a> oppure ritorna al <a href="../portal/newMenu.php">menù</a> principale.</h3>
            </center>
        </div>

        <? }else{ ?>
        <?php include '../portal/header.php';?>
        <div id="container">

            <div id="container2">
                <div id="header">
                    <center>
                        <h3><center>Nuovo Studente</center></h3>
                    </center>
                </div>
                <div id="navigation">
                    <ul>
                        <li><a href="../portal/newMenu.php"><center><img src="../images/icons/64/home.png" height="40" width="40"  border="0" title="Home"/></center></a></li>
                    </ul>
                </div>
                <div id="extra">
                    Questa sezione ti permette di creare un nuovo studente e inserirlo in una classe
                </div>
                <div id="content">
                    <center>
              
                        <form method="POST" action="nuovoStudenteListener.php">
                            <table cellpadding="8">
                                <tr>
                                    <td>Nome :</td>
                                    <td> <input type="text" name="nome"/></td>
                                </tr>
                                <tr>
                                    <td>Cognome </td>
                                    <td><input type="text" name="cognome" /></td>
                                </tr>
                                <tr>
                                    <td>E-mail:</td>
                                    <td><input type="text" name="email" /></td>
                                </tr>
                                <tr>
                                    <td>Assegna alla classe:</td>
                                    <td>
                                        <select name="codiceClasse">
                                            <?php
                                           
                                            while($result->fetch())
                                            {
                                                echo '<option value="'.$codiceClasse.'">'.$classe.'° ' . $sezione .' '. $descrizione . '</option>';
                                            }
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input type="submit" value="Inserisci"/>
                                    </td>
                                </tr>
                            </table>
                        </form>
                            
                        <br><br><br><br><br><br><br><br><br><br>
                    </center>
                </div>
                <div id="footer"><strong>© Info test on line</strong></div>

            </div>
        </div>
        <?}?>
    </body>
</html>
